package com.onluy.conf.rabbitmq;

import com.onluy.mqcomsumer.MessageType;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory;
import org.springframework.boot.autoconfigure.amqp.SimpleRabbitListenerContainerFactoryConfigurer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.amqp.core.Queue;

@Configuration
public class RabbitDirectConfig {


    @Bean
    public   Queue queuelog() {
        return new Queue(MessageType.log.name());
    }

    @Bean
    public Queue queuemail() {
        return new Queue(MessageType.mail.name());
    }

    @Bean
    DirectExchange onluywebExchange() {
        return new DirectExchange("onluywebExchange");
    }

    @Bean
    public Binding bindinglog() {
        return BindingBuilder.bind(queuelog()).to(onluywebExchange()).with(MessageType.log.name());
    }

    @Bean
    public Binding bindingmail() {
        return BindingBuilder.bind(queuemail()).to(onluywebExchange()).with(MessageType.mail.name());
    }




}
